<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html style='height: 100%;'>
<head>
<base href="<%=basePath%>">

<title>特定事件审批</title>
<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="static/p_house/house_index.css" />
<link rel="stylesheet" type="text/css" href="js/webuploader-0.1.5/webuploader.css" />

<script src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>
<script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="js/sharefunction.js"></script>
<script src="js/select2/select2.min.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js"></script>
<style>
.webuploader-container {
	position: relative;
	top: 5px;
}
</style>
</head>
<script type="text/javascript">
	var eventFlag; //查看状态
	$(function() {
		getFiles();
		//初始化表单
		mySubmit("eventAddForm", initEventData, eventAddSuccess);
		initWebUpload("filePicker_erul", "list_erul", "资料上传", "eventRecord_articleId", planStageSuccess, planStageErr);
		//上传按钮添加默认宽高
		$("div[id^='filePicker_'] div").css({
			"width" : "60px",
			"height" : "28px"
		});
		$("#eventAddForm").find("input,textarea").attr("readonly", true);
		$("#eventAddForm").find(".addbtn,select,.Wdate").attr("disabled", true);
		$("#eventAddForm div[id^='filePicker']").css("display", "none");
		$("#eventAddForm [name='remark']").attr("readonly",false);
		$("#eventAddForm input[name='eventDate']").val(new Date("${requestScope.event.eventDate}").format('yyyy-MM-dd'));
		toolTip();
		//修改字段标记记录变量
		
		<c:set var="marks" value="原数据"/>
	});
	function getFiles() {
		getFileListByFlag($("#eventAddForm input[name='eventId']").val(), "资料上传",2, "#list_erul", setRFL, imgPlus);
		<c:if test="${requestScope.notPassExamine}"> 
		//添加编辑时的临时附件数据
		var caList=[${requestScope.caList}];
		if(caList.length > 0){
			var erul = "";//资料id
			for(var i=0;i<caList.length;i++){
				erul += (","+caList[i].accessoryCAId);
			}
			if(erul != ""){
				getFileTempList(erul.substring(1),"#list_erul",setRFL,imgPlus);
			}
		}
		</c:if>
	}
	function imgPlus(data) {
		$("#eventAddForm .uploadcancel").css("display", "none");
		$.each(data, function(i, v) {
			//图片放大
			PostbirdImgGlass.init({
				domSelector : "#" + v.id + " img",
				animation : true,
				height : '80%',
				myDocument : window.parent.parent.parent
			});
		});

	}
	//设置待删除附件的值到集合中
	function setRFL(id, _this) {
		layer.confirm('删除该图片？', {
			title : '警告',
			icon : 0,
			shade : [ 0.1, '#fff' ]
		}, function() {
			//删除指定缩略图
			$("#" + id).remove();
			layer.close(layer.index);
		});
	}
	
	var obj;
	//obj 审批提交选项，1 同意，0拒绝
	function eventSubmit(val) {
		obj = val;
		$("#eventAddForm").submit();
	}

	function initEventData() {
		var mli = layer.load(2);
		var remark = $("#eventAddForm [name='remark']").val();
		var pendingId = $("#eventAddForm [name='pendingId']").val();
		var exDataId = $("#eventAddForm [name='exDataId']").val();
		if (remark == "") {
			layer.msg("审批说明不能为空");
			$("#eventAddForm [name='remark']").focus();
			layer.close(mli);
			return null;
		} else {
			return {
				remark : remark,//编辑时填写备注
				pendingId : pendingId,
				spflag :obj,
				exDataId:exDataId
			}
		}

	}
	//上传成功回调
	function eventAddSuccess(data, status) {
		if (status == "success") {
			layer.alert("保存成功！", {
				offset : '20%',
				shade : [ 0.1, '#fff' ]
			}, function() {
				parent.location.reload();
			//layer.close(eventi);
			});
		} else {
			layer.alert('保存失败！');
		}
	}
</script>
<body>
	<form class="cmxform" id="eventAddForm" method="post" action="customer/event/doEventPending">
		<div>
			<!-- 上传文件返回的附件id -->
			<input type="text" id="eventRecord_articleId" name="eventRecord_articleId" value="" hidden="hidden" style="display: none;" />
			<div class="panel panel-default">
				<div class="panel-body ">
					<table cellpadding="10" cellspacing="5" class="mytable">
						<tr>
							<td width="73" class="td-right">事件类型</td>
							<td>
								<select class="js-example-basic-single" name="eventType" id="eventType" style="width: 160px;">
									<option selected="selected">${requestScope.event.eventType}</option>
								</select>
								<c:if test="${not empty requestScope.map.eventType }">
									<span class="toolTip mark-msg" data-tip="${requestScope.map.eventType}"> <c:out value="${marks}" /></span>
								</c:if>
								<c:if test="${requestScope.map.eventType=='' }">
									<span class="toolTip mark-msg" data-tip="空"> <c:out value="${marks}" /></span>
								</c:if>
							</td>
							<td width="73" class="td-right">发生时间</td>
							<td>
								<input name="eventDate" id="eventDate" class="Wdate" "
								readonly="readonly" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd'})">
								<c:if test="${not empty requestScope.map.eventDate }">
									<span class="toolTip mark-msg" data-tip="${requestScope.map.eventDate}"> <c:out value="${marks}" /></span>
								</c:if>
								<c:if test="${requestScope.map.eventDate=='' }">
									<span class="toolTip mark-msg" data-tip="空"> <c:out value="${marks}" /></span>
								</c:if>
							</td>
						</tr>

						<tr>
							<td width="73" class="td-right">事件描述</td>
							<td>
								<textarea rows="3" cols="80" style="width: 70%;" id="eventContent" name="eventContent">${requestScope.event.eventContent}</textarea>
								<c:if test="${not empty requestScope.map.eventContent }">
									<span class="toolTip mark-msg" data-tip="${requestScope.map.eventContent}"> <c:out value="${marks}" /></span>
								</c:if>
								<c:if test="${requestScope.map.eventContent=='' }">
									<span class="toolTip mark-msg" data-tip="空"> <c:out value="${marks}" /></span>
								</c:if>
							</td>
							<td width="73" class="td-right">处置过程</td>
							<td>
								<textarea rows="3" cols="80" style="width: 70%;" id="eventProcess" name="eventProcess">${requestScope.event.eventProcess}</textarea>
								<c:if test="${not empty requestScope.map.eventProcess }">
									<span class="toolTip mark-msg" data-tip="${requestScope.map.eventProcess}"> <c:out value="${marks}" /></span>
								</c:if>
								<c:if test="${requestScope.map.eventProcess=='' }">
									<span class="toolTip mark-msg" data-tip="空"> <c:out value="${marks}" /></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td width="73" class="td-right">参与人</td>
							<td colspan="3">
								<input name="eventParticipant" id="eventParticipant" value="${requestScope.event.eventParticipant}">
								<c:if test="${not empty requestScope.map.eventParticipant }">
									<span class="toolTip mark-msg" data-tip="${requestScope.map.eventParticipant}"> <c:out value="${marks}" /></span>
								</c:if>
								<c:if test="${requestScope.map.eventParticipant=='' }">
									<span class="toolTip mark-msg" data-tip="空"> <c:out value="${marks}" /></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td width="73" class="td-right">上传资料</td>
							<td colspan="3">
								<div id='filePicker_erul' style="display: none;">上传</div>
							</td>
						</tr>
						<tr>
							<!--上传资料 用来显示缩略图 -->
							<td colspan="4">
								<div id='list_erul'></div>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<c:if test="${ requestScope.notPassExamine }">
			<!-- 修改时添加变更说明 -->
			<div id="remark">
				审批说明：
				<textarea rows="3" style="width: 70%" name="remark"></textarea>
				<span style="color: red;">*</span>
			</div>
			<div style="width: 100%; text-align: center; padding-top: 20px">
				<!-- 保存状态 -->
				<button class="btn btn-danger radius" onClick="eventSubmit(1);" type="button">同意</button>
				<button class="btn btn-default radius" onClick="eventSubmit(0);" type="button">拒绝</button>
			</div>
			</c:if>
			<input name="exDataId" id="exDataId" hidden="hidden" value="${requestScope.exDataId }">
			<input name="pendingId" id="pendingId" hidden="hidden" value="${requestScope.pendingId }">
			<input name="eventId" id="entityId_eventId" hidden="hidden" value="${requestScope.event.id }">
		</div>
	</form>
	<script type="text/javascript">
		$(function() {
			//$("div[id^='filePicker_']").css("display", "inline-block");
		});
		//上传成功回调
		function planStageSuccess(file, response) {
			//图片放大初始化
			PostbirdImgGlass.init({
				domSelector : "td img",
				animation : true,
				myDocument : window.parent.parent.parent
			});
		//alert("上传成功回调");
		}
		//上传失败回调
		function planStageErr(file, data) {
			//alert("上传失败回调");
		}
	</script>
</body>